local skel = fk.CreateSkill {
  name = "emo__daxing",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__daxing"] = "大兴",
  [":emo__daxing"] = "锁定技，摸牌阶段，改为检索一张装备牌，获得其中与之同色的牌。",

  ["$emo__daxing1"] = "建非常之功，立万世之基，斯之谓大业！",
  ["$emo__daxing2"] = "汉帝营洛，徒劳民力，焉似朕之新都？",
}

skel:addEffect(fk.EventPhaseStart, {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Draw and not data.phase_end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    data.phase_end = true
    local ids, color = {}, 0
    while #room.draw_pile > 0 and player:isAlive() do
      local cid = room:getNCards(1)[1]
      table.insertIfNeed(ids, cid)
      room:moveCardTo(cid, Card.Processing, nil, fk.ReasonJustMove, skel.name)
      if Fk:getCardById(cid).type == Card.TypeEquip then
        color = Fk:getCardById(cid).color
        break
      end
      room:delay(100)
    end
    if not player.dead then
      local get = table.filter(ids, function (id)
        return Fk:getCardById(id).color == color and room:getCardArea(id) == Card.Processing
      end)
      if #get > 0 then
        room:delay(600)
        room:obtainCard(player, get, true, fk.ReasonJustMove, player, skel.name)
      end
    end
    room:cleanProcessingArea(ids)
  end,
})

return skel
